import {Controller, Post, Body, UseInterceptors} from "@nestjs/common";
import { SysConfigService } from './sysConfig.service';
import { SysConfigListDto, SysConfigUpdateDto } from './dto';
import {ApiOperation, ApiTags} from "@nestjs/swagger";
import {LoggingInterceptor} from "@/common/interceptor/logging.interceptor";
import { operationTypeEnum } from '@/common/enum';

@ApiTags("系统配置")
@Controller('sysConfig')
export class SysConfigController {
  constructor(private readonly roleService: SysConfigService
              ) {}
    @Post("/sysConfig")
    @ApiOperation({description:"系统配置"})
    @UseInterceptors(new LoggingInterceptor({data:"获取系统配置",logType:"operationLog",operationType:operationTypeEnum.search}))
    sysConfig(@Body() sysConfigDto: SysConfigListDto ) {
        return this.roleService.sysConfig(sysConfigDto.key);
    }

    @Post('/sysConfigUpdate')
    @ApiOperation({description:"更新系统配置"})
    @UseInterceptors(new LoggingInterceptor({data:"更新系统配置",logType:"operationLog",operationType:operationTypeEnum.edit}))
    sysConfigUpdate(@Body() sysConfigUpdateDto: SysConfigUpdateDto) {
        return this.roleService.sysConfigUpdate(sysConfigUpdateDto);
    }

}
